package com.bw.controller;

import com.alibaba.fastjson.JSONObject;
import com.bw.dao.impl.CustomerDaoImpl;
import com.bw.pojo.vo.CustomerVo;
import com.bw.pojo.vo.GoodsVo;
import com.bw.service.impl.CustomerServiceImpl;
import com.bw.util.PageResult;
import com.github.pagehelper.PageInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/customer/*")
public class CustomerController extends BaseController{
    CustomerServiceImpl service = new CustomerServiceImpl();
    protected void getCustomerList(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.接收参数 2.将json转对象 3.将对象丢给Service 4.响应用户123123123
        String reqInfos = req.getParameter("reqInfos");
        CustomerVo customerVo = JSONObject.parseObject(reqInfos, CustomerVo.class);
        //返回 分页工具类对象
        PageInfo<CustomerVo> list = service.getCustomerList(customerVo);
        resp.getWriter().println(JSONObject.toJSONString(list));
    }
}
